Chris Pollett > Old Classes >
CS152

( Print View )

Student Corner:
  [Grades Sec1]

  [Submit Sec1]

  [Class Sign Up Sec1]

  [
Lecture Notes]
  [Discussion Board]

Course Info:
  [Texts & Links]
  [Topics/Outcomes]
  [Outcomes Matrix]
  [Grading]
  [HW Info]
  [Exam Info]
  [Regrades]
  [Honesty]
  [Additional Policies]
  [Announcements]

HW Assignments:
  [Hw1]  [Hw2]  [Hw3]
  [Hw4]  [Hw5]  [Hw6]

Practice Exams:
  [Mid]  [Final]

                           












HW#6 --- last modified February 28 2019 22:32:16..

Solution set.

Due date: Dec 10

Files to be submitted:
  Hw6.zip

Purpose: To understance how call and stack frames work. To gain more practice with ML. To write a simple Prolog program.

Related Course Outcomes:

The main course outcomes covered by this assignment are:

(2)[Have a basic knowledge of the procedural, object-oriented, functional, and logic programming paradigms.]

(4) [Critique the design of a programming language]

(10)[Understand the implementation of procedure calls and stack frames.]

Specification:

This assignment consists of three relatively small mini-assignments. All of your code should be submitted in Hw6.zip . The first thing I would like you to do is write a C program which when run from the command line with a line like:

./reverse somestring

outputs the command line argument supplied backwards. i.e., somestring would become gnirtsemos. Your implementation of this should be recursive. (BTW, I had a friend at Nvidia who was able to eliminate a lot of potential job applicants with this question). I want you to write a file stack.txt where you should what the activation records in stack would look like after each function invocation on the input hello.

For the second part of the assignment, I want you to write an essay (no more than 2-3 pages), essay.txt, comparing ML's module system with Java's package mechanism and C++ namespace mechanisms. Your essay should also include example working code snippets to illustrate your points. You should also discuss the uses you can think of for signatures.

For the last part of the assignment I want you to write a Prolog program roman.P which is run from the command prompt by supplying the goal startroman. This then prompts the user for a Roman number less than a million. (see Wikipedia, for letters with lines over them, imagine they are written as \bar{letter}. So \bar{M} is a million. Your program should then output the English word equivalent of that number. So the input LI would output fifty-one.

Point Breakdown

Reverse string program (reverse.c) compile and works as described 1pt
stack.txt is correct 2pt
essay.txt content (2pts), examples (1pt) 3pts
roman.P works as described. 4pts
Total10pts